package com.xiaoyu.lingdian.service.impl;

import java.util.Map;
import java.util.List;
import java.util.HashMap;
import com.xiaoyu.lingdian.core.mybatis.page.Page;
import com.xiaoyu.lingdian.core.mybatis.page.PageRequest;
import com.xiaoyu.lingdian.service.CoreRepairTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xiaoyu.lingdian.core.mybatis.dao.MyBatisDAO;
import com.xiaoyu.lingdian.entity.CoreRepairType;

@Service("coreRepairTypeService")
public class CoreRepairTypeServiceImpl implements CoreRepairTypeService {

	@Autowired
	private MyBatisDAO myBatisDAO;

	@Override
	public boolean insertCoreRepairType(CoreRepairType coreRepairType) {
		myBatisDAO.insert(coreRepairType);
		return true;
	}

	@Override
	public boolean updateCoreRepairType(CoreRepairType coreRepairType) {
		myBatisDAO.update(coreRepairType);
		return true;
	}

	@Override
	public boolean deleteCoreRepairType(CoreRepairType coreRepairType) {
		myBatisDAO.delete(coreRepairType);
		return true;
	}

	private static final String DELETEBATCH_COREREPAIRTYPE_BY_IDS="deleteBatchCoreRepairTypeByIds";
	@Override
	public boolean deleteBatchByIds(List<String> list ) {
		Map<String, Object> hashMap = new HashMap<String, Object>();
		hashMap.put("list", list);
		myBatisDAO.delete(DELETEBATCH_COREREPAIRTYPE_BY_IDS,hashMap);
		return true;
	}

	@Override
	public CoreRepairType getCoreRepairType(CoreRepairType coreRepairType) {
		return (CoreRepairType) myBatisDAO.findForObject(coreRepairType);
	}

	private static final String FIND_COREREPAIRTYPE_FOR_LISTS="findCoreRepairTypeForLists";

	@SuppressWarnings("unchecked")
	@Override
	public List<CoreRepairType> findCoreRepairTypeList() {
		return myBatisDAO.findForList(FIND_COREREPAIRTYPE_FOR_LISTS, null);
	}
	
	private static final String FIND_COREREPAIRTYPE_FOR_PAGES="findCoreRepairTypeForPages";

	@SuppressWarnings("unchecked")
	@Override
	public Page<CoreRepairType> findCoreRepairTypePage(int pageNum, int pageSize, String crrteName) {
		Map<String, Object> hashMap = new HashMap<String, Object>();
		hashMap.put("crrteName", crrteName);
		return myBatisDAO.findForPage(FIND_COREREPAIRTYPE_FOR_PAGES, new PageRequest(pageNum, pageSize, hashMap));
	}

//<=================定制内容开始==============
//==================定制内容结束==============>

}